package org.atlantis.grosbeak.castor;

import java.lang.reflect.Type;
import java.util.ArrayList;

@SuppressWarnings("unchecked")
public class ArrayListToArray implements Castor<ArrayList, String[]> {

	public Type getFrom() {
		return ArrayList.class;
	}

	public Type getTo() {
		return String[].class;
	}

	public String[] obverseCast(ArrayList src, Class<?> toType)
			throws FailToCastException {
		String[] strs = new String[src.size()];
		int i = 0;
		for (Object obj : src) {
			String str = (String) obj;
			strs[i++] = str + "Atlantis";
		}
		return strs;
	}

	public ArrayList reverseCast(String[] src, Class<?> toType)
			throws FailToCastException {
		ArrayList list = new ArrayList();
		for (String str : src) {
			list.add(str + "SeeNoEvil");
		}
		return list;
	}
}
